<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of RenderOffer
 *
 * @author Marcin
 */
class Zend_View_Helper_RenderOffer extends Zend_View_Helper_Abstract{
    //put your code here
    public function renderOffer(Application_Model_Offer $offer,$options = null) {
        
        $config = array();
        $config['renderGroups'] = true;
        $config['showResults'] = true;
        $config['editable'] = true;
        
        if(!empty($options)) {
            foreach ($options as $key => $value) {
                $config[$key] = $value; 
            }
        }
        
        if($offer->getFirstOffer() == 1) {
            echo $this->view->partial('partials/_offer.phtml',  array(
                'offer' => $offer)
            ); 
        } else {
            echo $this->view->partial('partials/_simpleOffer.phtml',  array(
                'offer' => $offer)
            ); 
        }
        echo '<div class="results'.$offer->getOffer_id().'"></div>';
        if($config['editable']) {

            echo $this->view->partial('partials/_offerEdit.phtml',  array(
            'id' => $offer->getOffer_id())
        ); 
        }
        echo '<br/>';
        
        echo '<br/>';

//        $groups = $offer->getGroups();
//        var_dump($groups);
        //dodać wyświetlanie grup
        foreach ($offer->getGroups() as $group){
            echo '<div id="group'.$group->getGroup_id().'" class="nested vpad_10 bg_lightblue">';
            echo $this->view->RenderGroup($group,$options);
            echo '</div><br/>';
        }
    }
}

?>
